﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MyMeetup.Entities;

namespace MyMeetup.Helpers
{
    public class GroupAdapter : IGroup
    {
        private IGroupSearchItem _searchItem;
        
        public GroupAdapter(IGroupSearchItem searchItem)
        {
            _searchItem = searchItem;
      
        }


        public double lon
        {
            get { return double.Parse(_searchItem.lon); }
            set { _searchItem.lon = value.ToString(); }
        }

        public JoinInfo join_info
        {
            get { return new JoinInfo(); }
            set {  }
        }

        public string visibility
        {
            get { return _searchItem.visibility; }
            set { _searchItem.visibility = value; }
        }

        public string link
        {
            get { return _searchItem.link; }
            set { _searchItem.link = value; }
        }

        public Organizer organizer
        {
            get { return new Organizer() {member_id = int.Parse(_searchItem.organizer_id), name = _searchItem.organizer_name}; }
            set
            {
                _searchItem.organizer_id = value.member_id.ToString();
                _searchItem.organizer_name = value.name;
            }
        }

        public string join_mode
        {
            // "open", "closed", "approval" or "invite"
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public string who
        {
            get { return _searchItem.who; }
            set { _searchItem.who = value; }
        }

        public int id
        {
            get { return int.Parse(_searchItem.id); }
            set { _searchItem.id = value.ToString(); }
        }


        public Photo group_photo
        {
            get
            {
                return new Photo()
                           {
                               thumb_link = _searchItem.photo_url,
                               photo_link = _searchItem.photo_url,
                               highres_link = _searchItem.photo_url
                           };
            }
            set { _searchItem.photo_url = value.thumb_link ?? value.photo_link ?? value.highres_link ?? ""; }
        }

        public long created
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public string description
        {
            get { return _searchItem.description; }
            set { _searchItem.description = value; }
        }

        public string name
        {
            get { return _searchItem.name; }
            set { _searchItem.name = value; }
        }

        public double rating
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public string urlname
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public double lat
        {
            get { return double.Parse(_searchItem.lat); }
            set { _searchItem.lat = value.ToString(); }
        }

        public int members
        {
            get { return int.Parse(_searchItem.members);}
            set { _searchItem.members = value.ToString(); }
        }

        public GroupSelf self
        {
            get { return new GroupSelf();}
            set { }
        }
    }
}
